/*
 * GUIObjectFactory.cpp
 *
 *  Created on: 09/11/2009
 *      Author: marcos
 */

#include "GUIObjectFactory.h"

#include "gui/objects/intersections/GUIAvenueIntersection.h"
#include "gui/objects/intersections/GUIHighwayIntersection.h"
#include "gui/objects/intersections/GUIIntersection.h"
#include "gui/objects/intersections/GUIRouteIntersection.h"
#include "gui/objects/intersections/GUIStreetIntersection.h"
#include "gui/objects/locations/GUIHospital.h"
#include "gui/objects/locations/GUIHotel.h"
#include "gui/objects/locations/GUISchool.h"
#include "gui/objects/locations/GUIMapLocation.h"
#include "gui/objects/locations/GUIPoliceStation.h"
#include "gui/objects/locations/GUIRestaurant.h"
#include "gui/objects/locations/GUIUnknownLocation.h"
#include "gui/objects/segments/GUIAvenueSegment.h"
#include "gui/objects/segments/GUIBaseSegment.h"
#include "gui/objects/segments/GUIHighwaySegment.h"
#include "gui/objects/segments/GUIStreetSegment.h"
#include "gui/objects/segments/GUIRoadArrow.h"
#include "gui/objects/segments/GUIRoadSegment.h"
#include "gui/objects/segments/GUIRouteSegment.h"
#include "gui/objects/segments/GUIRouteArrow.h"

namespace gui {

GUIObjectFactory::GUIObjectFactory(GUIObjectDrawer* drawer) {
	this->drawer = drawer;
}

GUIObjectFactory::~GUIObjectFactory() {}

GUIObject* GUIObjectFactory::createGUIMapLocation(MapLocation* mapLocation){

	switch (mapLocation->getType()) {
		case Hotel: 		return new GUIHotel(drawer, mapLocation);
		case School: 		return new GUISchool(drawer, mapLocation);
		case Hospital: 		return new GUIHospital(drawer, mapLocation);
		case Restaurant: 	return new GUIRestaurant(drawer, mapLocation);
		case PoliceStation: return new GUIPoliceStation(drawer, mapLocation);
		default: 			return new GUIUnknownLocation(drawer, mapLocation);
	}
}

GUIObject* GUIObjectFactory::createGUIBaseSegment(RoadSegment* roadSegment){
	return new GUIBaseSegment(drawer, roadSegment);
}

GUIObject* GUIObjectFactory::createGUIRoadSegment(RoadSegment* roadSegment){
	GUIObject* guiRoadSegment = NULL;
	switch (roadSegment->getRoad()->getRoadType()) {
		case Avenue: guiRoadSegment = new GUIAvenueSegment(drawer, roadSegment); break;
		case Highway: guiRoadSegment = new GUIHighwaySegment(drawer, roadSegment); break;
		default: guiRoadSegment = new GUIStreetSegment(drawer, roadSegment); break;
	}
	return guiRoadSegment;
}

GUIObject* GUIObjectFactory::createGUIRoadArrow(RoadSegment* roadSegment, bool inverted){
	return new GUIRoadArrow(drawer, roadSegment, inverted);
}

GUIObject* GUIObjectFactory::createGUIRouteSegment(MapPoint origin, MapPoint destination){
	return new GUIRouteSegment(drawer, origin, destination);
}

GUIObject* GUIObjectFactory::createGUIRouteArrow(MapPoint origin, MapPoint destination){
	return new GUIRouteArrow(drawer, origin, destination);
}

GUIObject* GUIObjectFactory::createGUIIntersection(MapPoint intersection, RoadType type){
	GUIObject* guiIntersection = NULL;
	switch (type) {
		case Highway: guiIntersection = new GUIHighwayIntersection(drawer, intersection); break;
		case Avenue: guiIntersection = new GUIAvenueIntersection(drawer, intersection); break;
		default: guiIntersection = new GUIStreetIntersection(drawer, intersection); break;
	}
	return guiIntersection;
}

GUIObject* GUIObjectFactory::createGUIRouteIntersection(MapPoint intersection){
	return new GUIRouteIntersection(drawer, intersection);
}

GUICar* GUIObjectFactory::createGUICar(map::Car* car) {
	return new GUICar(drawer, car);
}

}
